//
//  HTMainTableViewController.swift
//  weibo
//
//  Created by JonsonLiu on 16/4/16.
//  Copyright © 2016年 liujonson. All rights reserved.
//

import UIKit

class HTMainTController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //点击中间加号按钮弹窗
        //var index = 1 ?? 0
        
        let compoButtomClick = {
        
            print("窗口弹出来了")
            let composeView = HTComposeView()
            self.view.addSubview(composeView)
            composeView.show(self)

        }
        
        let tabBar = HTTabBar()
        
        self.setValue(tabBar, forKey: "tabBar")
        
        tabBar.compoButtomClick = compoButtomClick
        
        
        
        
        addChildViewController(HTHomeController(),title: "首页",imageName: "tabbar_home")
        addChildViewController(HTDiscoverController(),title: "发现", imageName: "tabbar_discover")
        addChildViewController(HTMessageController(),title: "消息", imageName: "tabbar_message_center")
        
        
        addChildViewController(HTProfileController(),title: "我" , imageName: "tabbar_profile")
//        addChildViewController(HTDiscoverController() , title : "发现")

    }

    func addChildViewController(vc : UIViewController , title : String , imageName: String){
    
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")?.imageWithRenderingMode(.AlwaysOriginal)
        
        //设置字体颜色
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor .orangeColor()], forState: .Selected)
        //设置字体大小
//        vc.tabBarItem.setTitleTextAttributes([NSFontAttributeName:UIFont.boldSystemFontOfSize(30)], forState: .Normal)
        
        addChildViewController(UINavigationController(rootViewController: (vc)))
    
    }
}